import { createRouter, createWebHistory } from "vue-router";
// import Login from '@/pages/Login/login.vue'
// import MainBox from '@/pages/MainBox/MainBox.vue'
import Home from "@/pages/Home/Home.vue";
import User from "@/pages/userCenter/User.vue";
import addBlog from "@/pages/blog/addBlog.vue";
import getBlog from "@/pages/blog/getBlog.vue";
const routes = [
  {
    path: "/mainBox",
    component: () => import("@/pages/MainBox.vue"),
    name: "mainBox",
    children: [
      {
        path: "index",
        component: Home,
        name: "home",
      },
      {
        path: "user",
        component: User,
        name: "User",
      },
      {
        path: "myBlog/addBlog",
        component: addBlog,
        name: "addBlog",
      },
      {
        path: "myBlog/getBlog",
        component: getBlog,
        name: "getBlog",
      },
      {
        path: "userManage/addUser",
        component: () => import("@/pages/userManage/addUser.vue"),
        name: "addUser",
      },
      {
        path: "userManage/getUser",
        component: () => import("@/pages/userManage/getUser.vue"),
        name: "getUser",
      },
      {
        path: '/:catchAll(.*)',
        component: ()=>import('@/pages/404.vue'),
        name: 'notFound'
      }
    ],
  },
  {
    path: "/login",
    component: () => import("@/pages/Login.vue"),
    name: "login",
  },
  {
    path: "/",
    redirect: "/mainBox/index",
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});
// router.beforeEach((to, from, next) => {
//   console.log(from, "from");
//   console.log(to, to.path, "to");
//   next();
// });

export default router;
